#include <QPainter>
#include "package.h"

Package::Package(pt::PackageType p,int v):Object()
{
    type=ot::PACKAGE;
    ptype=p;
    value=v;
    alive=true;
    if(ptype==pt::HEALTH)texture=QPixmap(":/resources/medical_kit.png");
    else if(ptype==pt::SHIELD)texture=QPixmap(":/resources/defence.png");

}

void Package::set(pt::PackageType t,int v)
{
    ptype=t;
    value=v;
}

void Package::purge()
{
    hide();
    alive=false;
    purgatory->purge(this,type);

}

void Package::control()
{

}

void Package::physics()
{

}

void Package::step()
{

}

void Package::paint(QPainter *painter, const QStyleOptionGraphicsItem *,QWidget *)
{
    painter->drawPixmap(boundingRect().toRect(),texture);
}

QRectF Package::boundingRect() const
{
    const static QRectF r(-texture.width()/2,-texture.height()/2,texture.width(),texture.height());
    return r;

}
